package com.fcy.teamwork.business.newjob

import androidx.lifecycle.ViewModel
import com.fcy.teamwork.App
import com.fcy.teamwork.pojo.Job
import com.fcy.teamwork.pojo.TeamWorkResult
import com.fcy.teamwork.repo.RetrofitClient
import retrofit2.http.Body
import retrofit2.http.POST
import java.util.*

class NewJobVM : ViewModel() {
    interface NewJob {
        @POST("/sms/job/newJob")
        suspend fun newJob(@Body job: Job): TeamWorkResult<Job>
    }

    private val service = RetrofitClient.getService<NewJob>()
    suspend fun submitJob(job: Job):TeamWorkResult<Job> {
        job.ownerId = App.person.personId
        job.createTime = Date()
        job.isResolved = 0
        return service.newJob(job)
    }
}